package com.example.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReadUtils {
    public static Map<String,Long> getWeatherAreaCode(String filename) throws IOException {
        Map<String,Long> WeatherAreaCode=new HashMap<>();
        File file=new File(filename);
        // 带缓冲的流读取，默认缓冲区8k
        try (BufferedReader br = new BufferedReader(new FileReader(file))){
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
                String key=line.substring(0,line.indexOf(":"));
                Long value=Long.valueOf(line.substring(line.indexOf(":"),line.indexOf(",")));
                WeatherAreaCode.put(key,value);
            }
        }
        return WeatherAreaCode;
    }
}
